package com.tengfei.blogsystem.dao;

import com.tengfei.blogsystem.pojo.FriendsLink;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

/**
 * @version v1.0
 * @author} feige
 * @date 2021-10-21-19:35
 * @description
 */
public interface LinkDao extends JpaRepository<FriendsLink, String>, JpaSpecificationExecutor<FriendsLink> {

    @Modifying
    @Query(nativeQuery = true, value = "update `tb_friends` set `state`='0',`update_time`=? where `id`=?")
    int deleteLinkByUpdateState(Date update, String linkId);

    FriendsLink findOneById(String linkId);
}
